import { getRequest } from "@/api/request";
import { AxiosResponse } from "axios";
import { translateCount } from "@/utils/util";
const REQUEST_URL = {
  songList: "/personalized",
};

const filter = (res: AxiosResponse) => {
  return res.data.result.map((songList: songList) => {
    return {
      id: songList.id,
      name: songList.name,
      picUrl: songList.picUrl,
      playCount: translateCount(songList.playCount),
    };
  });
};

export const getSongList = (limit: number) => {
  return getRequest(REQUEST_URL.songList, { limit: limit }).then(filter);
};
